import http from "../request";
const apibase = "/api/RouteOperation"
import qs from 'qs'


//新增关联工序
var insRouteoperation = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/InsRouteoperation`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//修改关联工序

var updRouteoperation = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/UpdRouteoperation`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//删除关联工序
var delRouteoperation = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/DelRouteoperation`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//新增SOP
var insOperationSOP = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/InsOperationSOP`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//修改SOP
var updOperationSOP = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/UpdOperationSOP`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//删除SOP
var delOperationSOP = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/DelOperationSOP`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//SOP模板下载
var soptemplateDownload = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/SOPTemplateDownload?${qs.stringify(data)}`, )
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//SOP导入
var sopImport = function(data) {
	return new Promise((resolve, reject) => {
		http.Filepost(apibase + `/SOPImport`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//查询附件
var getEnclosureList = function(data) {
	return new Promise((resolve, reject) => {
		http.get(apibase + `/GetEnclosureList/GetEnclosureList/${data}`, )
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//下载附件
var downloadEnclosure = function(data) {
	return new Promise((resolve, reject) => {
		http.get(apibase + `/downloadEnclosure/downloadEnclosure/${data}`, )
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//删除附件
var delEnclosureRelation = function(data) {
	return new Promise((resolve, reject) => {
		http.Filepost(apibase + `/DelEnclosureRelation`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
export {
	insRouteoperation,
    updRouteoperation,
    delOperationSOP,
    updOperationSOP,
    insOperationSOP,
    delRouteoperation,
	soptemplateDownload,
	sopImport,
	getEnclosureList,
	downloadEnclosure,
	delEnclosureRelation
}
